package net.javoft;

import com.google.gwt.core.ext.Generator;
import com.google.gwt.core.ext.GeneratorContext;
import com.google.gwt.core.ext.PropertyOracle;
import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;

public class WelcomeGenerator extends Generator{

	@Override
	public String generate(TreeLogger logger, GeneratorContext context,
			String typeName) throws UnableToCompleteException {
		try{
			if("net.javoft.client.WelcomeImpl".equals(typeName)){
				PropertyOracle propOracle = context.getPropertyOracle();
				String userAgent = propOracle.getPropertyValue(logger, "user.agent");
				if(userAgent.equals("ie8")){
					return "net.javoft.client.WelcomeImplIE";
				}else if("gecko".equals(userAgent) || "gecko1_8".equals(userAgent)){
					return "net.javoft.client.WelcomeImplFF";
				}else {
					return "net.javoft.client.WelcomeImpl";
				}
			}else{
				throw new UnableToCompleteException();
			}
		}catch(Exception e){
			
		}
		return null;
	}

}
